package com.tledu.email.service.impl;

import java.util.List;

import com.tledu.common.utils.DateUtils;
import com.tledu.common.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.tledu.email.mapper.EmailTableOutboxMapper;
import com.tledu.email.domain.EmailTableOutbox;
import com.tledu.email.service.IEmailTableOutboxService;

/**
 * 邮箱发件箱Service业务层处理
 *
 * @author ruoyi
 * @date 2024-08-29
 */
@Service
public class EmailTableOutboxServiceImpl implements IEmailTableOutboxService {
    @Autowired
    private EmailTableOutboxMapper emailTableOutboxMapper;

    /**
     * 查询邮箱发件箱
     *
     * @param id 邮箱发件箱主键
     * @return 邮箱发件箱
     */
    @Override
    public EmailTableOutbox selectEmailTableOutboxById(Long id) {
        return emailTableOutboxMapper.selectEmailTableOutboxById(id);
    }

    /**
     * 查询邮箱发件箱列表
     *
     * @param emailTableOutbox 邮箱发件箱
     * @return 邮箱发件箱
     */
    @Override
    public List<EmailTableOutbox> selectEmailTableOutboxList(EmailTableOutbox emailTableOutbox) {
        return emailTableOutboxMapper.selectEmailTableOutboxList(emailTableOutbox);
    }

    /**
     * 新增邮箱发件箱
     *
     * @param emailTableOutbox 邮箱发件箱
     * @return 结果
     */
    @Override
    public int insertEmailTableOutbox(EmailTableOutbox emailTableOutbox) {
        emailTableOutbox.setCreateTime(DateUtils.getNowDate());
        return emailTableOutboxMapper.insertEmailTableOutbox(emailTableOutbox);
    }

    /**
     * 修改邮箱发件箱
     *
     * @param emailTableOutbox 邮箱发件箱
     * @return 结果
     */
    @Override
    public int updateEmailTableOutbox(EmailTableOutbox emailTableOutbox) {
        emailTableOutbox.setUpdateTime(DateUtils.getNowDate());
        return emailTableOutboxMapper.updateEmailTableOutbox(emailTableOutbox);
    }

    /**
     * 批量删除邮箱发件箱
     *
     * @param ids 需要删除的邮箱发件箱主键
     * @return 结果
     */
    @Override
    public int deleteEmailTableOutboxByIds(Long[] ids) {
        return emailTableOutboxMapper.deleteEmailTableOutboxByIds(ids);
    }

    /**
     * 删除邮箱发件箱信息
     *
     * @param id 邮箱发件箱主键
     * @return 结果
     */
    @Override
    public int deleteEmailTableOutboxById(Long id) {
        return emailTableOutboxMapper.deleteEmailTableOutboxById(id);
    }

    // 查询当前用户发件箱的信息
    @Override
    public List<EmailTableOutbox> sendList(EmailTableOutbox emailTableOutbox) {
        Long userId = SecurityUtils.getUserId();
        emailTableOutbox.setCreateId(userId);
        return emailTableOutboxMapper.sendList(emailTableOutbox);
    }

    // 根据条件查找当前用户发件箱信息
    @Override
    public List<EmailTableOutbox> selectByCondition(EmailTableOutbox emailTableOutbox) {
        Long userId = SecurityUtils.getUserId();
        emailTableOutbox.setCreateId(userId);
        return emailTableOutboxMapper.selectByCondition(emailTableOutbox);
    }

    // 逻辑删除用户发件箱的内容，实际上是进行更新操作
    @Override
    public int updateSymbol(Long[] ids) {
        return emailTableOutboxMapper.updateSymbol(ids);
    }
}
